package com.yunang.officialweb.service.impl;

import com.yunang.officialweb.entity.NumbersIntroduce;
import com.yunang.officialweb.entity.TotalDesc;
import com.yunang.officialweb.mapper.NumberMapper;
import com.yunang.officialweb.mapper.ProjectMapper;
import com.yunang.officialweb.service.AUService;
import com.yunang.officialweb.service.HomeService;
import com.yunang.officialweb.service.NumberService;
import com.yunang.officialweb.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class NumberServiceImpl implements NumberService {
    @Resource
    private NumberMapper numberMapper;

    @Autowired
    private HomeService homeService;

    @Autowired
    private AUService auService;

    @Autowired
    private ProjectService projectService;


    @Override
    public List<NumbersIntroduce> getNumbersIntroduce() {
        return numberMapper.getNumbersIntroduce();
    }


    @Override
    public Object updateNumberIntroduce(NumbersIntroduce numbersIntroduce) {
        return numberMapper.updateNumbersIntroduce(numbersIntroduce);
    }



    @Override
    public Map<String, Object> getExcellentNumber(){
        Map<String, Object> exNuMap = new HashMap<>();
        Map<String, Object> comIntMap = new HashMap<>();
        Map<String, Object> auMap = new HashMap<>();
        Map<String, Object> comSerMap = new HashMap<>();
        Map<String, Object> totalMap = new HashMap<>();

        TotalDesc comSer = homeService.getCompanyServices();
        comSerMap.put("services", comSer.getEnglishName());
        comSerMap.put("serviceTitle", comSer.getChineseName());
        comSerMap.put("serviceDesc", comSer.getText());
        comSerMap.put("servicesProject",  projectService.selectAll());

        TotalDesc comInt = homeService.getCompanyIntroduce();
        comIntMap.put("companyName",comInt.getChineseName());
        comIntMap.put("companyDesc", comInt.getDesc1());
        comIntMap.put("Iamge", comInt.getImage());

        TotalDesc au = homeService.getAboutUs();
        auMap.put("aboutUsDesc", au.getDesc1());
        auMap.put("aboutUsText",au.getChineseName());
        auMap.put("aboutUs", au.getEnglishName());
        auMap.put("image", au.getImage());

        TotalDesc totalDesc = homeService.getExcellentNumber();
        exNuMap.put("EnglishText",totalDesc.getEnglishName());
        exNuMap.put("excellentNumbers",totalDesc.getChineseName());
        exNuMap.put("Desc",totalDesc.getDesc1());
        exNuMap.put("numbersIntroduce",numberMapper.getNumbersIntroduce());

        totalMap.put("companyIntroduce", comIntMap);
        totalMap.put("companyServices", comSerMap);
        totalMap.put("aboutUs", auMap);
        totalMap.put("excellentNumber", exNuMap);

        return totalMap;
    }

}
